<?php if (!defined('THINK_PATH')) exit(); /*a:4:{s:85:"D:\php\www\12.74.103.73\gh_pcyy_cn\public/../application/index\view\Index\modify.html";i:1655953525;s:74:"D:\php\www\12.74.103.73\gh_pcyy_cn\application\index\view\Common\head.html";i:1653381376;s:74:"D:\php\www\12.74.103.73\gh_pcyy_cn\application\index\view\Common\menu.html";i:1653377790;s:76:"D:\php\www\12.74.103.73\gh_pcyy_cn\application\index\view\Common\footer.html";i:1648437088;}*/ ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico" >
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
    <script type="text/javascript" src='/index/lib/html5.js'></script>
    <script type="text/javascript" src="/index/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="/index/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="/index/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="/index/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="/index/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="/index/static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" type="text/css" href="/index/media.css" />
    <link rel="stylesheet" type="text/css" href="/index/yy/style.css" />
    <script type="text/javascript" src="/index/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="/index/lib/datatables/1.10.0/jquery.tablesorter.min.js"></script>
    <script type="text/javascript" src="/layer/layer.js"></script>

	<title>深圳鹏程</title>
    <!--[if IE 6]>
    <script type="text/javascript" src="/index/static/h-ui.admin/js/DD_belatedPNG_0.0.8a-min.js" ></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <!--/meta 作为公共模版分离出去-->

    <style type="text/css">
        .menu>li>a{color:#000000;}
        #hello{

        }
        #hell-icon{
            width: 18px;
            height: 18px;
            border-radius: 50%;
            background-color: red;
            float: right;
            margin-top: -35px;
            margin-right: -25px;
            position: relative;
            line-height: 18px;
            text-align: center;
            display: none;
        }
        #hell-icon-xs{
            width: 18px;
            height: 18px;
            border-radius: 50%;
            background-color: red;
            float: left;
            position: absolute;
            right: 65px;
            top: 12px;
            line-height: 18px;
            text-align: center;
            display: none !important;

        }
    </style>

    <!--_header 作为公共模版分离出去-->
    <header class="navbar-wrapper">
        <div class="navbar navbar-fixed-top">
            <div class="container-fluid cl"> <a class="logo navbar-logo f-l mr-10 hidden-xs" href="/index/Index/listdata">深圳鹏程医院</a> <a class="logo navbar-logo-m f-l mr-10 visible-xs" href="/index/Index/listdata">深圳鹏程医院</a>
                <span class="logo navbar-slogan f-l mr-10 hidden-xs">v2.0</span>

                <a href="/index/Index/DeleteData" id="hell-icon-xs" class="navbar-logo-m visible-xs">0</a>
                <a aria-hidden="false" class="nav-toggle Hui-iconfont visible-xs" href="javascript:;">&#xe667;</a>

                <nav id="Hui-userbar" class="nav navbar-nav navbar-userbar hidden-xs">
                    <ul class="cl">


            <li class="dropDown dropDown_hover" ><div id="hello"></div>
                <a href="/index/Index/DeleteData"><div id="hell-icon">2</div></a>
            </li>

            <li class="dropDown dropDown_hover"> <a href="#" class="dropDown_A">退出 <i class="Hui-iconfont">&#xe6d5;</i></a>

                            <ul class="dropDown-menu menu radius box-shadow">
                                <li><a href="/index/Login/logout">切换账户</a></li>
                                <li><a href="/index/Set/updatepass">修改密码</a></li>
                                <li><a href="/index/Login/logout">退出</a></li>
                            </ul>
                        </li>

                        <li id="Hui-skin" class="dropDown right dropDown_hover"> <a href="javascript:;" class="dropDown_A" title="换肤"><i class="Hui-iconfont" style="font-size:18px">&#xe62a;</i></a>
                            <ul class="dropDown-menu menu radius box-shadow">
                                <li><a href="javascript:;" data-val="default" title="默认（黑色）">默认（黑色）</a></li>
                                <li><a href="javascript:;" data-val="blue" title="蓝色">蓝色</a></li>
                                <li><a href="javascript:;" data-val="green" title="绿色">绿色</a></li>
                                <li><a href="javascript:;" data-val="red" title="红色">红色</a></li>
                                <li><a href="javascript:;" data-val="yellow" title="黄色">黄色</a></li>
                                <li><a href="javascript:;" data-val="orange" title="橙色">橙色</a></li>
                            </ul>
                        </li>
                    </ul>
                </nav>
            </div>
        </div>
    </header>
    <script type="text/javascript">
        $(function(){
            //console.log(getCookie("auth"));
            //显示当前用户用户名
            $("#hello").html(getCookie("auth").split("-")[0]);

            function getCookie(name) {
                var cookies = document.cookie;
                var list = cookies.split("; ");          // 解析出名/值对列表
                    for(var i = 0; i < list.length; i++) {
                    var arr = list[i].split("=");          // 解析出名和值

                         if(arr[0] == name)
                             return decodeURIComponent(arr[1]);   // 对cookie值解码
                         } 
                return "";
            }

        });

        $.post("/index/Index/selectDeleteData",{"ids":0},function (e) {


            if(e>0){
                $("#hell-icon").show()
                $("#hell-icon").html(e)
                var w=$(window).width();
                if(w>800){

                }else{
                    $("#hell-icon-xs").css('cssText','display: block !important;')
                    $("#hell-icon-xs").html(e)
                }

            }
        })


    </script>
    <!--/_header 作为公共模版分离出去-->

<style type="text/css">

</style>

<!--_menu 作为公共模版分离出去-->
<aside class="Hui-aside">

    <div class="menu_dropdown bk_2">
        <ul>
            <?php if(is_array($qx) || $qx instanceof \think\Collection || $qx instanceof \think\Paginator): $i = 0; $__LIST__ = $qx;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;                if($vo['p_content']){
                ?>
<li><a href="<?php echo $vo['p_action']; ?>" title="<?php echo $vo['p_content']; ?>"><?php echo $vo['p_content']; ?></a></li>
            <?php
                }
            endforeach; endif; else: echo "" ;endif; 				if(isMobile()){
            ?>
            <li><a href="/index/Set/updatepass">修改密码</a></li>
            <li><a href="/index/Login/logout">退出</a></li>
            <?php
                }
			?>
        </ul>
    </div>
</aside>

<script type="text/javascript">
    function showtc(){
        layer.open({
            title:"添加",
            type: 2,
            area: ['900px', '600px'],
            fixed: false, //不固定
            maxmin: true,
            content: '/index/Index/tcadd'
        });
    }

    $(function(){
        //设置弹窗按钮的链接
        //$("ul li").getAttribute("title");
        $(".bk_2 ul li a").each(function(i){
            //不可更改，屏幕太小，不显示分析按钮
           if(this.title=="添加"&&document.body.clientWidth>760){
               this.href="javascript:showtc()";
           }

            if(this.title=="统计"&&document.body.clientWidth<760){
                console.log($(this).css("display","none"));
            }

            if(this.title=="项目统计"&&document.body.clientWidth<760){
                console.log($(this).css("display","none"));
            }
		


        });
    });


</script>

<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a></div>
<!--/_menu 作为公共模版分离出去-->


<link href="/index/yy/index.css" rel="stylesheet">
<link href="/index/yy/laydate.css" rel="stylesheet">
<script src="/index/yy/laydate.js"></script>
<script type="text/javascript" src="/index/laydate/laydate.js"></script>
<style type="text/css">
    *{font-size: 15px!important;}
    .submit,.reset{    cursor: pointer;}
    #test-limit3{  width: 40%;  height: 30px;  padding: 2px 5px;  font-size: 18px;  color: #555;  }
    #test-limit2{    height: 30px;  padding: 2px 5px;  font-size: 18px;  color: #555;  }
    .appointment .physician input{width:15px;height:15px;}
    .appointment .position input{width:15px;height:15px;}
    .colorred{color:red;}
    .phone,.yaoyue{height:40px;}
    .time_hour,.time_min{border: solid 1px #eee;font-size: 17px;}

    .check-box {
        width: 200px;
    }
</style>

<section class="Hui-article-box">

    <?php //dd($recode_data);?>
    <form class="appointment">
        <ul>
            <li>
                <h2>预约日期：</h2>
                <div class="laydate-box">
                    <input type="text" id="laydateInput" autocomplete="off" value="<?php //echo date('Y-m-d',$recode_data['riqi']);?>" />
                    <div class="select-date">
                        <div class="select-date-header">
                            <ul class="heade-ul">
                                <li class="header-item header-item-one">
                                    <select name="" id="yearList"></select>
                                </li>
                                <li class="header-item header-item-two" onselectstart="return false">
                                    <select name="" id="monthList"></select>
                                </li>
                                <li class="header-item header-item-three" onselectstart="return false">
                                    <span class="reback">回到今天</span>
                                </li>
                            </ul>
                        </div>
                        <div class="select-date-body">
                            <ul class="week-list">
                                <li>日</li><li>一</li><li>二</li><li>三</li><li>四</li><li>五</li><li>六</li>
                            </ul>
                            <ul class="day-tabel"></ul>
                        </div>
                    </div>
                </div>
            </li>

            <li>
                <!--
                <h2>时&ensp;&ensp;&ensp;&ensp;间：</h2>
                <input type="text" name="time" class="layui-input time" id="test-limit3"  value="<?php echo $recode_data['shijian']; ?>">
                -->

                <h2>时　　间：</h2>
                <select id="time_hour" class="time_hour" name="time_hour" style="width: 30%">
                   <!--  <option value="08">08</option> -->
                    <option value="09">09</option>
                    <option value="10">10</option>
                    <option value="11">11</option>
                    <option value="12">12</option>
                    <option value="13">13</option>
                    <option value="14">14</option>
                    <option value="15">15</option>
                    <option value="16">16</option>
                    <option value="17">17</option>
                    <option value="18">18</option>
                    <option value="19">19</option>
                </select>
                <select id="time_min" class="time_min" name="time_min" style="width: 30%">
                    <option value="00">00</option>
                    <option value="30">30</option>
                </select>

            </li>
            <li>
                <h2>卡号/手机：</h2>
                <input type="text" name="hongmai" autocomplete="off" class="layui-input input-text hongmai" id="test-limit2" value="<?php echo $recode_data['hongmai']; ?>">
            </li>
            <li>
                <h2>顾客姓名：</h2>
                <input type="text" name="name" autocomplete="off" class="layui-input name"  value="<?php echo $recode_data['name']; ?>">
            </li>


            <li>
                <h2>渠&ensp;&ensp;&ensp;&ensp;道：</h2>
                <select class="channel" name="from">
                    <?php
                        foreach($data[5]['value'] as $fk => $fv){
                    ?>
                    <option value="<?php echo $fv; ?>"><?php echo $fv; ?></option>
                    <?php
                        }
                    ?>
                </select>
            </li>

            <li>
                <h2>邀 约 人：</h2>
                <input type="text" name="yaoyue" autocomplete="off" class="input-text yaoyue" value="<?php echo $recode_data['yaoyue']; ?>"  placeholder="邀约人">
            </li>

            <li>
                <h2>治疗项目：</h2>
                <div class="position skin-minimal">
                    <!--<div class="check-box" ><input class="check_position" type="checkbox" name="position" value="其他" > <label>其他</label></div>-->
                    <?php
                            foreach($data[1]['value'] as $pk => $pv){
                    ?>
                    <div class="check-box"><input class="check_position" type="checkbox" name="position" value="<?php echo $pv; ?>" id="it_<?php echo $pk; ?>"> <label for="it_<?php echo $pk; ?>"><?php echo $pv; ?></label></div>
                    <?php
                            }
                        ?>
                </div>
            </li>

            <li>
                <h2>主任/医生：</h2>
                <div class="physician doctor">
                    <div class="check-box"><input class="doctor_class" id="do_c_wd" type="checkbox" name="doctor" value="无指定（科室安排）" > <label id="do_wd" for="do_wd">无指定（科室安排）</label></div>
                    <?php
                            foreach($data[4]['value'] as $dk => $dv){
                    ?>
                    <div class="check-box"><input class="doctor_class" id="do_c_<?php echo $dv; ?>" type="checkbox" name="doctor" value="<?php echo $dv; ?>" > <label id="do_<?php echo $dv; ?>" for="do_<?php echo $dv; ?>"><?php echo $dv; ?></label></div>
                    <?php
                        }
                    ?>
                </div>
            </li>
            <li>
                <h2>治疗师：</h2>
                <div class="meirongshi">
                    <div class="check-box"><input class="meirongshi_class" id="do_zl_c_wd" type="checkbox" name="meirongshi" value="无指定（科室安排）" > <label id="do_zl_wd" for="do_wd">无指定（科室安排）</label></div>
                    <?php
                            foreach($data[7]['value'] as $nk => $nv){
                    ?>
                    <div class="check-box" style="width:200px"><input class="meirongshi_class" id="do_c_<?php echo $nv; ?>" type="checkbox" name="meirongshi" value="<?php echo $nv; ?>" > <label id="do_<?php echo $nv; ?>" for="mr_<?php echo $nv; ?>"><?php echo $nv; ?></label></div>
                    <?php
                            }
                        ?>
                </div>
            </li>




            <li>
                <h2>设　　备：</h2>
                <div class="physician shebei">
                    <!--<div class="check-box"><input class="device_class" type="checkbox" name="device" value="其他"><label>其他</label></div>-->
                    <?php
                        foreach($data[0]['value'] as $dk => $dv){
                    ?>
                    <div class="check-box">
                        <input class="device_class" type="checkbox" name="device" value="<?php echo str_replace('[error]','',$dv); ?>" id="d_<?php echo $dk; ?>" <?php if(strpos($dv,"[error]")){echo "disabled";} ?>>
                        <label id="d_c_<?php echo $dk; ?>" for="d_<?php echo $dk; ?>" class='<?php if(strpos($dv,"[error]")){echo "colorred";} ?>'><?php echo str_replace('[error]','',$dv); ?></label>
                    </div>
                    <?php
                        }
                    ?>
                </div>
            </li>

            <li>
                <h2>预计时长：</h2>
                <select id="lengthtime" class="lengthtime" name="time_length">
                    <option value="1小时">1小时</option>
                    <option value="1.5小时">1.5小时</option>
                    <option value="2小时">2小时</option>
                    <option value="2.5小时">2.5小时</option>
                    <option value="3小时">3小时</option>
                    <option value="3.5小时">3.5小时</option>
                    <option value="4小时">4小时</option>
                </select>
            </li>
            <li>
                <h2>备&ensp;&ensp;&ensp;&ensp;注：</h2>
                <textarea class="message" name="message" rows="5"><?php echo $recode_data['content']; ?></textarea>
            </li>
            <li>
                <?php if($data['stype'] == '0'): ?>
                <input class="btn btn-success radius submit" type="button" value="修改">
                <input class="btn btn-danger radius" type="button" value="取消" style="margin-left: 10px" onclick="deleteRecode()">
                <?php endif; ?>


            </li>
        </ul>
    </form>

</section>
<script type="text/javascript">
    function deleteRecode(){
        ids = '<?php echo $recode_data['d_id']; ?>';

        $.post("/index/Index/deleteRecode",{"ids":ids},function (e) {
            if(e==1){
                $.Huimodalalert('删除成功',2000);
                sessionStorage.setItem('deleteType',1);
                history.back()
            }else if(e=="deny"){
                //无权限删除
                $.Huimodalalert('无权限进行该操作',1000);
            }
        })
    }

    $(function(){
        <?php
            if($recode_data['shebei']!="{'空'}"){
                foreach(json_decode($recode_data['shebei']) as $v){
                    echo "$(\".shebei input[value='"."$v"."']\").attr('checked',true);";
                }
            }

        if($recode_data['doctor']!="{'空'}"){
            foreach(json_decode($recode_data['doctor']) as $v){
                echo "$(\".doctor input[value='"."$v"."']\").attr('checked',true);";
            }
        }

        if($recode_data['buwei']!="{'空'}"){
            foreach(json_decode($recode_data['buwei']) as $v){
                echo "$(\".position input[value='"."$v"."']\").attr('checked',true);";
            }
        }
        if($recode_data['zhiliaoshi']!="{'空'}"){

                echo "$(\".zhiliaoshi input[value='"."$v"."']\").attr('checked',true);";

        }
        if($recode_data['meirongshi']!="{'空'}"){
            foreach(json_decode($recode_data['meirongshi']) as $v){
                echo "$(\".meirongshi input[value='"."$v"."']\").attr('checked',true);";
            }
        }
        if($recode_data['hushi']!="{'空'}"){
            foreach(json_decode($recode_data['hushi']) as $v){
                echo "$(\".hushi input[value='"."$v"."']\").attr('checked',true);";
            }
        }

        //设置时间
        $time_arr = explode(":",substr($recode_data['shijian'],0,5));

        ?>


        $(".time_hour option[value='<?php echo $time_arr[0]; ?>']").prop("selected","true");
        $(".time_min option[value='<?php echo $time_arr[1]; ?>']").prop("selected","true");
        $(".lengthtime option[value='<?php echo $recode_data['spendtime']; ?>']").prop("selected","true");
        $(".channel option[value='<?php echo $recode_data['from']; ?>']").prop("selected","true");



        //限定可选时间
        /*
        laydate.render({
            elem: '#test-limit3'
            ,type: 'time'
            ,min: '09:00:00'
            ,max: '20:00:00'
            ,btns: ['clear', 'confirm']
        });
         */
        $(".reset").click(function() {
            $(".appointment")[0].reset();
            $(".reback").click();
        });

        $(".submit").on("click",function(){
            positionType=0;

            //治疗项目
            obj = document.getElementsByName("position");

            check_val = [];
            for(k in obj){
                if(obj[k].checked)
                    check_val.push(obj[k].value);
            }
            if(check_val[0]=='化学焕肤'||check_val[0]=='黄金微针'||check_val[0]=='纹绣'||obj[k].value=='其他'){
                positionType=1;//仪器可以不选
            }

            //医生
            obj = document.getElementsByName("doctor");
            doctor_val = [];
            for(k in obj){
                if(obj[k].checked)
                    doctor_val.push(obj[k].value);
            }


            //设备
            obj = document.getElementsByName("device");
            device_val = [];
            for(k in obj){
                if(obj[k].checked)
                    device_val.push(obj[k].value);
            }
            //美容师
            obj = document.getElementsByName("meirongshi");
            meirongshi_val = [];
            for(k in obj){
                if(obj[k].checked)
                    meirongshi_val.push(obj[k].value);
            }


            if(check_val.length==0){
                alert("治疗项目必选");
                return false;
            }

            if(doctor_val.length==0&&meirongshi_val.length==0){
                alert("治疗人员选项必选");
                return false;
            }
            if(device_val.length==0&&positionType!=1){
                alert("仪器必选");
                return false;
            }


            date        = $("#laydateInput").val(); //预约日期
            zhiliaoshi= $(".zhiliaoshi").val(); //治疗室
            hongmai     = $(".hongmai").val();        //会员卡号
            time        = ($(".time_hour").val())+":"+($(".time_min").val());        //治疗时间 几点钟
            name        = $(".name").val();        //顾客姓名
            channel     = $(".channel").val();        //渠道
            yaoyue      = $(".yaoyue").val();        //邀约
            position    = check_val;        //治疗项目
            phone       = $(".phone").val();
            lengthtime  = $(".lengthtime").val();        //预计时长
            doctor      = doctor_val;        //医生
            device      = device_val;        //设备
            meirongshi  = meirongshi_val;        //美容师
            message     = $(".message").val();        //留言
            d_id        = <?php echo $recode_data['d_id']; ?>;

            if(hongmai.length==0||name.length==0||yaoyue.length==0){
                alert("会员卡号、顾客姓名、邀约人不能为空");
                return false;
            }

            var postdata = {
                "date":date,
                "hongmai":hongmai,
                "time":time,
                "name":name,
                "yaoyue":yaoyue,
                "phone":phone,
                "channel":channel,
                "position":position,
                "lengthtime":lengthtime,
                "doctor":doctor,
                "zhiliaoshi":zhiliaoshi,
                "meirongshi":meirongshi_val,
                "device":device,
                "message":message,
                "d_id":d_id
            };
            //console.log(postdata);

            $.post("/index/Index/modifydata",postdata,function(e){
                //console.log(e);
                if(e==1){
                    $.Huimodalalert('更新成功',2000);

                }else{

                }
            });

        });

        if(document.body.clientWidth>760){
            //弹出式添加页面，隐藏左边菜单栏
            $("body").addClass("big-page");
            $(".dislpayArrow").css("display","none");
            $(".navbar-wrapper").css("display","none");
        }

    });

    var stype="<?php echo $data['stype']; ?>" //1为查看标识

    function getSelectDate(result){
        //排班信息显示
        date        = $("#laydateInput").val(); //预约日期
        if(date==null)date=result;
        var postdata = {
            "date":date
        };

        $.post("/index/Index/getPaiban",postdata,function(e){
            for(k in e){
                //console.log(e[k].name);
                if(e.code==2&&k!='code'){
                    document.getElementById("do_"+e[k]).innerText=e[k];
                }else if(e.code==1&&k!='code'){
                    document.getElementById("do_"+e[k].name).innerText=e[k].name+"("+e[k].work+")";
                }
            }
        });


    }

    //$recode_data['riqi']

    setTimeout("formatDateTime()",1000);
    function formatDateTime() {
        timeStamp = <?php echo $recode_data['riqi']; ?>;
        var date = new Date();
        date.setTime( timeStamp * 1000);
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var h = date.getHours();
        h = h < 10 ? ('0' + h) : h;
        var minute = date.getMinutes();
        var second = date.getSeconds();
        minute = minute < 10 ? ('0' + minute) : minute;
        second = second < 10 ? ('0' + second) : second;
        //return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
        riqi = y + '-' + m + '-' + d;
        //console.log(riqi);
        $("#laydateInput").val(riqi);

        getSelectDate(riqi);
        getPosition()
    }



    function getSelectDate(result){
        if(stype==1){return false;}

        //治疗项目
        obj = document.getElementsByName("position");
        check_val = [];
        for(k in obj){
            if(obj[k].checked)
                check_val.push(obj[k].value);
        }

        //排班信息显示
        date        = $("#laydateInput").val(); //预约日期
        time        = ($(".time_hour").val())+":"+($(".time_min").val());        //治疗时间 几点钟
        position    = check_val;        //治疗项目
        d_id        = '<?php echo $recode_data['d_id']; ?>';

        time_number=Number(($(".time_hour").val())+"."+($(".time_min").val()));

        var postdata = {
            "date":date,"time":time,"position":position,"did":d_id
        };

        //console.log(postdata);
        $.post("/index/Index/getPaiban",postdata,function(e){

            //console.log(e);
            for(k in e){
                //console.log(e[k].name);
                if(e.code==2&&k!='code'){
                    document.getElementById("do_"+e[k]).innerText=e[k];
                }else if(e.code==1&&k!='code'){
                    document.getElementById("do_"+e[k].name).innerText=e[k].name+"("+e[k].work+")";

                    item =document.getElementById("do_c_"+e[k].name);

                    if(e[k].work!='早'&&e[k].work!='晚'&&e[k].work!='补早'&&e[k].work!='补晚'&&e[k].work!='中'){
                        item.disabled='1';
                    }else if(e[k].disabled=='1'){//有预约
                        item.disabled='1';item.checked=false;
                        document.getElementById("do_"+e[k].name).innerText=e[k].name+"(预)";
                    }else if(e[k].disabled=='2'){//超过时间
                        item.disabled='1';item.checked=false;
                        document.getElementById("do_c_wd").disabled='1';//无指定选项
                        document.getElementById("do_zl_c_wd").disabled='1';//无指定选项
                    }else if(e[k].position=='2'){//项目过滤
                        item.disabled='1';item.checked=false;
                    }
                    else if((e[k].work=='晚'||e[k].work=='补晚')&&time<'11'){
                        item.disabled='1';item.checked=false;
                    }else if((e[k].work=='早'||e[k].work=='补早')&&time_number>=17.3){
                        item.disabled='1';item.checked=false;
                    } else if((e[k].work=='中'||e[k].work=='补中')&&(time_number>=19||time_number<10)){
                        item.disabled='1';item.checked=false;
                    } else{
                        item.disabled='';
                        document.getElementById("do_c_wd").disabled='';//无指定选项
                        document.getElementById("do_zl_c_wd").disabled='';//无指定选项
                    }
                }

            }
        });


        getSelectDevice();
        updateTImeMin();
    }

    $('.doctor_class').change(function(){//医生单选设置
        item=document.getElementsByClassName("doctor_class");
        for(key in item){
            if(item[key].value==$(this).val()){
            }else{
                item[key].checked=false;
            }
        }
    })
    $('.meirongshi_class').change(function(){
        item=document.getElementsByClassName("meirongshi_class");
        for(key in item){
            if(item[key].value==$(this).val()){
            }else{
                item[key].checked=false;
            }
        }
    })
    $('.device_class').change(function(){
        item=document.getElementsByClassName("device_class");
        for(key in item){
            if(item[key].value==$(this).val()){
            }else{
                item[key].checked=false;
            }
        }
    })
    $('.check_position').change(function(){
        item=document.getElementsByClassName("check_position");
        for(key in item){
            if(item[key].value==$(this).val()){
            }else{
                item[key].checked=false;
            }
        }
    })


    //getSelectDate();
    $("#time_hour").change(function(data){
        getSelectDate();
        updateTImeMin();
    })
    $("#time_min").change(function(data){
        getSelectDate();
    })
    $(".check_position").change(function(data){//治疗项目触发
        getSelectDate();
        //console.log('check_position');
        getPosition()
    })

    function getPosition(){//更新预约时长
        if(stype==1){return false;}
        getData()
        var postdata = {
            "position":position[0]
        };
        $.post("/index/Index/getPosition",postdata,function(e){
            var htmllet='';
            for(k in e.data){
                htmllet +="<option value='"+e.data[k]+"小时'>"+e.data[k]+"小时</option>";
            }
            document.getElementById("lengthtime").innerHTML=htmllet;
            $(".lengthtime option[value='<?php echo $recode_data['spendtime']; ?>']").prop("selected","true");
        });
    }

    function updateTImeMin(){//更新分钟
        time_hour=$(".time_hour").val()
        if(time_hour==8){
            htmllet ='<option value="30">30</option>';
        }else{
            htmllet ='<option value="00">00</option> <option value="30">30</option>';
        }
        document.getElementById("time_min").innerHTML=htmllet;
    }

    function getSelectDevice(){//设备更新
        if(stype==1){return false;}
        getData()
        var postdata = {
            "date":date,"time":time,"lengthtime":lengthtime,"device":device[0],"did":d_id,"position":position[0]
        };
        //console.log(postdata);
        $.post("/index/Index/getDevice",postdata,function(e){
            //console.log(e);
            for(k in e){
                if(e.code==1&&k!='code'&&k!='deviceStr'){
                    document.getElementById("d_c_"+k).innerText=e[k].name+"("+e[k].number+")";
                    itemD=document.getElementById("d_"+k);
                    if(e[k].number<=0){
                        itemD.disabled='1';
                        itemD.checked=false;
                        document.getElementById("d_c_"+k).innerText=e[k].name+"(0)";
                        if(e[k].deviceStr!=''){
                            $.Huimodalalert(device[0]+':'+e[k].deviceStr+'已在该使用范围内请重新选择',5000);
                            window.close();
                        }
                    }else if(e[k].filterType==1){//项目过滤设备
                        itemD.disabled='';
                        itemD.checked=true;
                    }else if(e[k].filterType==0){//项目过滤设备
                        itemD.disabled='1';
                        itemD.checked=false;
                    }else{
                        itemD.disabled='';
                    }
                }
            }
        });
    }



    $(".lengthtime").change(function(data){
        if(stype==1){return false;}
        getData()
        var postdata = {
            "date":date,"time":time,"lengthtime":lengthtime,"doctor":doctor[0],"meirongshi":meirongshi[0],"did":d_id
        };
        if(doctor!=''||meirongshi!=''){
            $.post("/index/Index/updateLengthtime",postdata,function(e){//判断预约时长
                //console.log(e);
                if(e.code==1){

                    $.Huimodalalert('预约时长不在范围内请重新选择：'+e.freeTimedata,5000);
                    window.close();

                    $(".lengthtime").val('30分钟')
                }
            });
        }else if(doctor==''&&meirongshi==''){
            $.Huimodalalert('请选择治疗人员',2000);
            window.close();

            $(".lengthtime").val('30分钟')
        }
        getSelectDevice()//设备更新
    })






    function getData(){//获取数据
        //治疗项目
        obj = document.getElementsByName("position");
        check_val = [];
        for(k in obj){
            if(obj[k].checked)
                check_val.push(obj[k].value);
        }
        //医生
        obj = document.getElementsByName("doctor");
        doctor_val = [];
        for(k in obj){
            if(obj[k].checked)
                doctor_val.push(obj[k].value);
        }
        //美容师
        obj = document.getElementsByName("meirongshi");
        meirongshi_val = [];
        for(k in obj){
            if(obj[k].checked)
                meirongshi_val.push(obj[k].value);
        }
        //设备zhiliaoshi
        obj = document.getElementsByName("device");
        device_val = [];
        for(k in obj){
            if(obj[k].checked)
                device_val.push(obj[k].value);
        }

        position    = check_val;        //治疗项目
        lengthtime  = $(".lengthtime").val();        //预计时长
        doctor      = doctor_val;         //医生
        meirongshi  = meirongshi_val;        //美容师
        device      = device_val;        //
        d_id        = '<?php echo $recode_data['d_id']; ?>';
    }
</script>
<!--_footer 作为公共模版分离出去-->

<script type="text/javascript" src="/index/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/index/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="/index/static/h-ui.admin/js/H-ui.admin.page.js"></script>
<script type="text/javascript" src="/index/js/hd.js"></script>

<!--/_footer /作为公共模版分离出去-->
